<?php
$data= array(
		"b" => $touclickB,
		"z" => $touclickZ,
		"v" => $touclickV,
		"d" => $touclickD,
		"pf" => $touclickPF,
		"srf" => "1001"
		);

$resRep = touclick_request("http://api.touclick.com/statreport.touclick", $data, 80);
if($resRep['content'] == "alert"){
	cpmsg("{$touclicklang['alert']}", "", 'error');
}elseif($resRep['content'] == "wait"){
	cpmsg("{$touclicklang['wait']}", "", 'error');
}elseif($resRep['content'] == "live"){
	cpmsg("{$touclicklang['live']}", "action=plugins&cp=$cp&pmod=activate&operation=$operation&do=$do", 'error');
}
$reportTable = $tcJSON->decode($resRep['content'], true);
showtipss($touclicklang['tcmsg0011'],'tips1',true,$touclicklang['tipsTitle4']);
showtableheader("{$touclicklang['todaybrief']}");
echo "<tr class='header'><th>{$touclicklang['request']}</th><th>{$touclicklang['success']}</th><th>{$touclicklang['fail']}</th><th>{$touclicklang['complete']}</th><th>{$touclicklang['tcmsg0018']}</th></tr>";
if(is_array($reportTable) && count($reportTable) > 0){
	echo "<tr class='hover'><td>{$reportTable[0][get]}</td><td>{$reportTable[0][succes]}</td><td>{$reportTable[0][fail]}</td><td>{$reportTable[0][complete]}</td><td><label onclick='gotoDetail();'>{$touclicklang['tcmsg0017']}</label></td></tr>";
}else{
	echo "<tr class='hover'><td>0</td><td>0</td><td>0</td><td>0</td></tr>";
}
showtablefooter();
showtableheader("{$touclicklang['yesterdaybrief']}");
echo "<tr class='header'><th>{$touclicklang['request']}</th><th>{$touclicklang['success']}</th><th>{$touclicklang['fail']}</th><th>{$touclicklang['complete']}</th><th>{$touclicklang['tcmsg0018']}</th></tr>";

if(is_array($reportTable) && count($reportTable) > 1){
	echo "<tr class='hover'><td>{$reportTable[1][get]}</td><td>{$reportTable[1][succes]}</td><td>{$reportTable[1][fail]}</td><td>{$reportTable[1][complete]}</td><td><label onclick='gotoDetail();'>{$touclicklang['tcmsg0017']}</label></td></tr>";
}else{
	echo "<tr class='hover'><td>0</td><td>0</td><td>0</td><td>0</td></tr>";
}
showtablefooter();

echo <<<EOF
<script type="text/JavaScript">
function gotoDetail(){window.location.href="admin.php?action=plugins&cp=statReportDetail&pmod=report&operation=$operation&do=$do"}
</script>
EOF;

?>
